using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Globalization;
using System.Security.Cryptography;
using System.Collections.Generic;
using UnityEngine;
public static class MD5Helper
{
    public static string ToMD5_From_Sring(this string normal_String)
    {
        string result =string.Empty;


        MD5 md5 = MD5.Create(normal_String);
        return result;

    }
    public static string ToString_From_MD5(this string MD5_String)
    {
        string result = string.Empty;



        return result;
    }
}


public class Base64Helper : MonoBehaviour
{
    /// <summary>
    /// string 转 base64   
    /// </summary>
    public static string GetBase64(string input_)
    {
        byte[] b = System.Text.Encoding.Default.GetBytes(input_);
        //转成 Base64 形式的 System.String  
        string result = Convert.ToBase64String(b);

        return result;
    }


    /// <summary>
    /// 转回到原来的 System.String:  
    /// </summary>
    public static string GetOrignalStr(string input_)
    {
        byte[] c = Convert.FromBase64String(input_);
        string a = System.Text.Encoding.Default.GetString(c);

        return a;
    }

}

public class MD5Helper3 : MonoBehaviour
{
    public static string GetMD5(string input_)
    {
        byte[] buffer = Encoding.Default.GetBytes(input_);
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] output = md5.ComputeHash(buffer);
        string result2 = BitConverter.ToString(output).Replace("-", "");

        return result2;
    }
}

namespace WindowsApplication2
{
    class MD5
    {
        // 创建Key  
        public string GenerateKey()
        {
            DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)DESCryptoServiceProvider.Create();
            return ASCIIEncoding.ASCII.GetString(desCrypto.Key);
        }
        // 加密字符串  
        public string EncryptString(string sInputString, string sKey)
        {
            byte[] data = Encoding.UTF8.GetBytes(sInputString);
            DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
            DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
            DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
            ICryptoTransform desencrypt = DES.CreateEncryptor();
            byte[] result = desencrypt.TransformFinalBlock(data, 0, data.Length);
            return BitConverter.ToString(result);
        }
        // 解密字符串  
        public string DecryptString(string sInputString, string sKey)
        {
            string[] sInput = sInputString.Split("-".ToCharArray());
            byte[] data = new byte[sInput.Length];
            for (int i = 0; i < sInput.Length; i++)
            {
                data[i] = byte.Parse(sInput[i], NumberStyles.HexNumber);
            }
            DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
            DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
            DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
            ICryptoTransform desencrypt = DES.CreateDecryptor();
            byte[] result = desencrypt.TransformFinalBlock(data, 0, data.Length);
            return Encoding.UTF8.GetString(result);
        }

    }
}